package com.paw.es7.config;

import io.swagger.annotations.ApiOperation;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;

/**O
 * @author: lvzihai
 * @date: 2021/5/18
 **/

@Configuration
public class Swagger2Config {

  @Bean
  public Docket createRestApi() {


    return  new Docket(DocumentationType.OAS_30)
        .useDefaultResponseMessages(true)
        .apiInfo(apiInfo())
        .select()
        .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
        .paths(PathSelectors.any())
        .build();

  }

  private ApiInfo apiInfo() {
    return new ApiInfoBuilder()
        .title("Paw APIs")
        .description("knife4j")
        .termsOfServiceUrl("https://mp.weixin.qq.com/s/CVPhbX80JN8DQLqQ82vQ3g")
        .version("3.0")
        .build();
  }

}
